package com.jiuzhou.guanwang.jzcp.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jiuzhou.guanwang.jzcp.R;
import com.jiuzhou.guanwang.jzcp.base.BaseRecyclerAdapter;
import com.jiuzhou.guanwang.jzcp.base.BaseRecyclerHolder;
import com.jiuzhou.guanwang.jzcp.bean.ExpertBean;
import com.jiuzhou.guanwang.jzcp.utils.GlideCircleTransform;

import java.util.List;

/**
 * @ explain:
 * @ author：xujun on 2016/10/18 16:42
 * @ email：gdutxiaoxu@163.com
 */
public class ExpertAdapter extends BaseRecyclerAdapter<ExpertBean> {
    private Context mContex;

    public ExpertAdapter(Context context, List<ExpertBean> datas) {
        super(context, R.layout.item_expert, datas);
        mContex = context;
    }

    @Override
    public void convert(BaseRecyclerHolder holder, ExpertBean item, int position) {
        holder.setText(R.id.tv_name, item.getAuthName());
        holder.setText(R.id.tv_desc, item.getAuthdescription());
        TextView tagTv = holder.getView(R.id.tv_tag);
        if( item.getAuthTag().contains("玩家")){
            tagTv.setTextColor(mContex.getResources().getColor(R.color.red));
            tagTv.setBackground(mContex.getResources().getDrawable(R.drawable.btn_with_border_red));
        }else if(item.getAuthTag().contains("彩票")){
            tagTv.setTextColor(mContex.getResources().getColor(R.color.blue1));
            tagTv.setBackground(mContex.getResources().getDrawable(R.drawable.btn_with_border_blue));
        }else if(item.getAuthTag().contains("TV")){
            tagTv.setTextColor(mContex.getResources().getColor(R.color.orange));
            tagTv.setBackground(mContex.getResources().getDrawable(R.drawable.btn_with_border_orange));
        }else{
            tagTv.setTextColor(mContex.getResources().getColor(R.color.purple));
            tagTv.setBackground(mContex.getResources().getDrawable(R.drawable.btn_with_border_purple));
        }
        holder.setText(R.id.tv_tag, item.getAuthTag());
        ImageView headView = holder.getView(R.id.icon);
        if(!TextUtils.isEmpty(item.getAuthheadImlUrl())){
            Glide.with(this.mContext).load(item.getAuthheadImlUrl()) .bitmapTransform(new GlideCircleTransform(mContext)).into(headView);
        }else{
            Glide.with(this.mContext).load("https://img.dongqiudi.com/soccer/data/logo/team/team_default.png").into(headView);
        }
    }

}
